﻿using DC2010.Objects;
using DC2010.Objects.Base;
using DC2010.Objects.Data;

namespace DC2010.Conditions
{
    public class C_IsItemOwner : ConditionLogic
    {
        public C_IsItemOwner(ConditionData cd)
            : base(cd)
        {
            ShortName = "Is item in right hand";
            LongName = "Checks if item is in right hand.";
        }

        public override bool CheckCondition(BaseObject aInvoker, BaseObject aTarget)
        {
            if ((aInvoker is CreatureData)&&(aTarget is ItemData))
            {
                CreatureData c = (CreatureData)aInvoker;
                ItemData i = (ItemData)aTarget;

                BaseObject bo = Root.I.GameSystem.GetOwnedObject(c.Id, i.Id);

                //do effect
                HandleEffects(bo!=null, aInvoker, aTarget);
                return bo != null;
            }

            return false;
        }
    }
}
